package org.chengn.level_easy.context2697;

/**
 * @Title: Context2697
 * @Author ChengN
 * @Package org.chengn.level_easy.context2697
 * @Date 2023/12/13 0:30
 * @description: 字典序最小回文串
 */
public class Context2697 {
    public String makeSmallestPalindrome(String s) {
        char[] res = new char[s.length()];
        int l = 0, r = s.length() - 1;
        while (l <= r) {
            char lC = s.charAt(l);
            char rC = s.charAt(r);
            char ch = lC;
            if (lC > rC) {
                ch = rC;
            }
            res[l++] = ch;
            res[r--] = ch;
        }

        return new String(res);
    }
}
